<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3D盒子</title>
  <style>
    body{
      perspective: 1500px;
    }
    .wrapper{
      position: relative;
      width: 200px;
      height: 200px;
      margin: 100px auto;
      transform-style: preserve-3d;
      transition: all 3s;
    }
    .wrapper div{
      position:absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      opacity: 0.7;
    }
    .wrapper div:nth-child(1) {
      background-color: orange;
      transform: translateZ(100px);
    }
    .wrapper div:nth-child(2) {
      background-color: red;
      transform: translateZ(-100px);
    }
    .wrapper div:nth-child(3) {
      background-color: green;
      transform: translateX(-100px) rotateY(-90deg);
    }
    .wrapper div:nth-child(4) {
      background-color: blue;
      transform: translateX(100px) rotateY(90deg);
    }
    .wrapper div:nth-child(5) {
      background-color: yellow;
      transform: translateY(-100px) rotateX(90deg);
    }
    .wrapper div:nth-child(6) {
      background-color: pink;
      transform: translateY(100px) rotateX(-90deg);
    }
    .wrapper:hover{
      transform: rotateY(240deg) rotateX(240deg) rotateZ(-180deg);
    }
  </style>
</head>
<body>
  <div class="wrapper">
    <div>前面</div>
    <div>后面</div>
    <div>左面</div>
    <div>右面</div>
    <div>上面</div>
    <div>下面</div>
  </div>
</body>
</html>